<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div>
        <table>
            <th colspan="2">用户登录</th>
            <tr>
                <td>
                    用户名：
                </td>
                <td>
                    <input id="user" onfocus="fouse()" onblur="blu()" type="text">
                </td>
            </tr>
            <tr>
                <td>
                    密码：
                </td>
                <td>
                    <input id="psw" type="password" onfocus="fouses()" onblur="blus()">
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <button onclick="sumbits()">登陆</button>
                </td>
            </tr>
        </table>
    </div>
</body>
<script type="text/javascript">
function fouse(){
    console.log('用户在输入名称')
}

function blu(){
    if (document.getElementById('user').value==''){
        alert('没用输入用户名')
    }
}

function fouses(){
    console.log('用户在输入密码')
}

function blus(){
    if (document.getElementById('psw').value==''){
        alert('没用输入密码')
    }
}

function sumbits(){
    if (document.getElementById('user').value==''){
        console.log('用户名为空');
    }
    if (document.getElementById('psw').value==''){
        console.log('密码为空');
    }
}
</script>
</html>